package com.ruoyi.service.card.impl;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.bot.FeishuBot;
import com.ruoyi.service.card.IFudiCardService;
import com.ruoyi.service.card.IGshCardService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * TODO
 *
 * @author chenchuan2
 * @date 2024-04-05 18:11:31
 */
@Service
@Slf4j
public class FudiCardServiceImpl implements IFudiCardService {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private FeishuBot feishuBot;


    @Override
    public boolean checkInput(String code) {

        return false;
    }

    @Override
    public String fudiQrCode() {
        return "";
//        HttpHeaders headers = new HttpHeaders();
//        headers.set("authorization", "Qvodte eyJhbGciOiJIUzUxMiIsInppcCI6IkRFRiJ9.eNoUy1ELgjAYheH_smtH-9zmN4UugoKMghQi687RBDMzt2VU9N_T2_c850uuviYJkcgRGSANRQVU6AhoiVVJNeoKJIs1hiUJiHvqEatIhVIpABEzFo-5dm7M_dBdvKG-a8ydOmMHY6et9CQB5EJywAgDYrubmXjXLvOd4JttesiyfSWK4ydyqyJfpJyNv4ex7cRe7waGc7_2srEzqbJFfcI2m8_J7w8AAP__.mdMITNhuwhTJia2oZ9WSJWVFONJv8sNWL2Eq1RQ38z_cj359Bd3czwJKwEEgXg22i4-oc86VxjqZRA88QeiZcw");
//
//        // 设置请求体
//        String requestBody = ""; // 如果需要发送请求体，请将其填充为具体的内容
//
//        // 构造请求实体
//        HttpEntity<String> requestEntity = new HttpEntity<>(requestBody, headers);
//
//        // 设置请求URL
//        String url = "https://fudi.mini.ocs.api.yaodinongye.com/wx/vipInfo/genVipElectronicCardParam";
//
//        // 发送POST请求
//        ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, requestEntity, String.class);
//
//        // 获取响应状态码
//        HttpStatus statusCode = responseEntity.getStatusCode();
//
//        // 获取响应体
//        String responseBody = responseEntity.getBody();
//
//        JSONObject json = JSONObject.parseObject(responseBody);
//        String message = json.getString("errmsg");
//        if (message.contains("成功")) {
//            //获取data
//            String data = json.getString("data");
//            try {
//                String s = AESCrypto.aesDecrypt(data);
//                return JSONObject.parseObject(s).getString("qrCode");
//            } catch (Exception e) {
//                feishuBot.sendFeishuMsg(message);
//                throw new RuntimeException("服务卡异常");
//            }
//        } else {
//            feishuBot.sendFeishuMsg(message);
//            throw new RuntimeException("服务卡异常");
//        }
    }
}
